﻿<internals:PageBase
    x:Class="JV.Com.Views.SearchResultPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:prism="using:Microsoft.Practices.Prism.StoreApps"
    xmlns:i="using:Microsoft.Xaml.Interactivity"
    xmlns:internals="using:JV.Com.Internals" RequestedTheme="Light"
    
    prism:ViewModelLocator.AutoWireViewModel="true">

    <Page.Resources>
        <CollectionViewSource x:Name="SearchResultSource" IsSourceGrouped="True" ItemsPath="Games" />
    </Page.Resources>

    <Grid>
        <ProgressRing HorizontalAlignment="Center" VerticalAlignment="Center" IsActive="{Binding InLoading}"
                                      Height="50" Width="50" Foreground="{StaticResource DataItemBorderThemeBrush}" />

        <Hub HorizontalContentAlignment="Stretch">
            <Hub.Transitions>
                <TransitionCollection>
                    <EntranceThemeTransition />
                </TransitionCollection>
            </Hub.Transitions>
            <Hub.Header>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="80"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <Button  x:Name="backButton" Style="{StaticResource NavigationBackButtonNormalStyle}"
                        Margin="-1,-1,39,0" 
                        VerticalAlignment="Top"
                        Command="{Binding GoBackCommand}"
                        AutomationProperties.Name="Back"
                        AutomationProperties.AutomationId="BackButton"
                        AutomationProperties.ItemType="Navigation Button"/>
                    <TextBlock x:Name="pageTitle" Text="{Binding PageTitle}" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1" 
                        VerticalAlignment="Top" IsHitTestVisible="false" TextWrapping="NoWrap" />
                    <SearchBox
                        Grid.Column="2" VerticalAlignment="Center"
                        Height="35" Width="270"
                        PlaceholderText="Rechercher" QueryText="{Binding Query}"
                        SuggestionsRequested="SearchBox_SuggestionsRequested"
                        QuerySubmitted="SearchBox_QuerySubmitted" />
                </Grid>
            </Hub.Header>
            <Hub.Sections>
                <HubSection>
                    <DataTemplate>
                        <GridView ItemsSource="{Binding Source={StaticResource SearchResultSource}}" ItemContainerStyle="{StaticResource LittleGridViewItemStyle}"
                                      IsItemClickEnabled="True" SelectionMode="None" ItemClick="Search_ItemClick">
                            <GridView.ItemTemplate>
                                <DataTemplate>
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <TextBlock Text="{Binding Title}" Style="{StaticResource SearchTitleItemTextBlockStyle}"
                                                       TextAlignment="Left" TextWrapping="Wrap" />
                                        <TextBlock Text="{Binding Support}" Grid.Row="1"
                                                       TextAlignment="Left" Style="{StaticResource SummaryItemTextBlockStyle}" />
                                    </Grid>
                                </DataTemplate>
                            </GridView.ItemTemplate>
                            <GridView.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <ItemsWrapGrid ItemWidth="300" />
                                </ItemsPanelTemplate>
                            </GridView.ItemsPanel>
                            <GridView.GroupStyle>
                                <GroupStyle HidesIfEmpty="False">
                                    <GroupStyle.HeaderTemplate>
                                        <DataTemplate>
                                            <Grid>
                                                <TextBlock Text="{Binding GroupTitle}" Style="{StaticResource SubheaderTextBlockStyle}" />
                                            </Grid>
                                        </DataTemplate>
                                    </GroupStyle.HeaderTemplate>
                                    <GroupStyle.Panel>
                                        <ItemsPanelTemplate>
                                            <ItemsWrapGrid  Orientation="Horizontal"/>
                                        </ItemsPanelTemplate>
                                    </GroupStyle.Panel>
                                </GroupStyle>
                            </GridView.GroupStyle>
                        </GridView>
                    </DataTemplate>
                </HubSection>
            </Hub.Sections>
        </Hub>
    </Grid>
</internals:PageBase>
